<?php
if (!defined('BASEPATH')) {
	exit('No direct script access allowed');
}

class Admin extends CI_Controller {

	function __construct() {
		parent::__construct();
		$this->load->library('breadcrumb');
	}

	function index() {
		if (!$this->ion_auth->logged_in()) {
			redirect('login', 'refresh');
		} else {
			$this->layout->set_title('Dashboard');

			$this->breadcrumb->clear();
			$this->breadcrumb->add_crumb('Dashboard');

			$data['primary_title'] = "<i class='ion-ios7-home'></i> Dashboard";
			$data['sub_primary_title'] = "Main page";

			//HAuth
			$data['providers'] = $this->hybridauthlib->getProviders();
      foreach($data['providers'] as $provider=>$d) {
          if ($d['connected'] == 1) {
              $data['providers'][$provider]['user_profile'] = $this->hybridauthlib->authenticate($provider)->getUserProfile();
          }
      }

			$this->layout->theme('back','admin/index', $data);
		}
	}
}
